import { reactive, toRefs } from "vue";

function useDrawer() {
  const handleCloseDrawer = (cb?: () => void) => {
    cb && cb();
    drawer.drawerTitle = "";
    drawer.open = false;
  };

  const handleOpenDrawer = (cb: () => void) => {
    drawer.open = true;
    cb && cb();
  };

  const drawer = reactive({
    open: false,
    drawerTitle: "",
    handleOpenDrawer,
    handleCloseDrawer,
  });

  return {
    ...toRefs(drawer),
  };
}

export default useDrawer;
